package exception;

import java.io.Serializable;
import java.util.Arrays;

public class Person implements Serializable {
    private int age;
    private String name;
    private String gender;
    private String[] otherInfo;
    public Person(){

    }


    @Override
    public String toString() {
        return "Person{" +
                "age=" + age +
                ", name='" + name + '\'' +
                ", gender='" + gender + '\'' +
                ", otherInfo=" + Arrays.toString(otherInfo) +
                '}';
    }

    public Person(int age, String name, String gender, String[] otherInfo) {
        this.age = age;
        this.name = name;
        this.gender = gender;
        this.otherInfo = otherInfo;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) throws IllegalAgeException {
        if(age<0|age>100){
            throw new IllegalAgeException("年龄不是很合理");
        }
            this.age = age;
            
    }


}
